package models

import (
	"gorm.io/gorm"
	"hitme/go-api/modules/db"
)

var UserModel = new(User)

// 用户表
type User struct {
	db.CommonModel
	Nickname  string    `gorm:"type:varchar(20);default:'';NOT NULL;comment:昵称" json:"nickname"`
	OpenId    string    `gorm:"type:varchar(255);default:'';NOT NULL;comment:微信id" json:"open_id"`
	Avatar    string    `gorm:"type:varchar(255);default:'';NOT NULL;comment:头像" json:"avatar"`
	Gender    int8      `gorm:"type:tinyint(1) unsigned;default:0;comment:用户性别[0:未知;1:男;2:女]" json:"gender"`
	Province  string    `gorm:"type:varchar(100);comment:省份" json:"province"`
	City      string    `gorm:"type:varchar(100);comment:城市" json:"city"`
}

func (m *User) TableName() string {
	return "user"
}

func (m *User) Model() *gorm.DB {
	return db.MysqlDB.Model(&m)
}